﻿function initChart() {
	
	var xmlhttp = getxmlhttp()
	xmlhttp.open('POST', 'http://localhost/serviceManager.1cws', true)
	xmlhttp.onreadystatechange = function() {OnReadyStateChange(xmlhttp)}
	xmlhttp.send('<?xml version="1.0" encoding="utf-8"?>'
		+'<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sm="http://itek-tv/addition/managers/servicemanager/">'
		+'<soap:Header/><soap:Body><sm:getToday></sm:getToday></soap:Body>'
		+'</soap:Envelope>'
	)
	
}

function getxmlhttp(){
	var xmlhttp
	try {
		xmlhttp = new ActiveXObject("MSXML2.XMLHTTP")
	} catch (e) {
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
		} catch (e) {
			xmlhttp = false
		}
	}
	
	if (!xmlhttp && typeof(XMLHttpRequest) != 'undefined')
		xmlhttp = new XMLHttpRequest()
		
	return xmlhttp
}

function OnReadyStateChange(xmlhttp) {
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			
			var chart = new GanttChart(document.all.chartToday);
			
			var recordset = xmlhttp.responseXML.getElementsByTagName("record")
			
			for (var i = 0; i < recordset.length; ++i) {
				record = recordset[i].attributes;
				
				chart
					.addPoint(new Array(record.getNamedItem("station").value, record.getNamedItem("station").value))
					.addValue(new Array(record.getNamedItem("offset").value, record.getNamedItem("length").value, ''));
			}
			chart.draw();
			
		}
	}
}
